<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> UDT Reference</title>
<link rel="stylesheet" href="udtdoc.css" type="text/css" />
</head>

<body>
<div class="ref_head">&nbsp;UDT Reference: Functions</div>

<h4 class="func_name"><strong>socket</strong></h4>
<p>The <b>socket</b> method creates a new UDT socket.</p>

<div class="code">UDTSOCKET socket(<br />
&nbsp; int <font color="#FFFFFF">af</font>,<br />
&nbsp; int <font color="#FFFFFF">type</font>,<br />
&nbsp; int <font color="#FFFFFF">protocol</font><br />
);</div>

<h5>Parameters</h5>
<dl>
  <dt><i>af</i></dt>
  <dd>[in] IP Family: AF_INET or AF_INET6.</dd>
  <dt><em>type</em></dt>
  <dd>[in] Type of the socket: SOCK_STREAM or SOCK_DGRAM.</dd>
  <dt><em>protocol</em></dt>
  <dd>[in] Ignored. For compatibility only.</dd>
</dl>

<h5>Return Value</h5>
<p>If no error occurs, <b>socket</b> returns the new UDT socket descriptor; otherwise, it returns UDT::INVALID_SOCK and the error information can be retrieved by <a 
href="error.htm">getlasterror</a>.</p>

<table width="100%" border="1" cellpadding="1" cellspacing="0" bordercolor="#CCCCCC">
  <tr>
    <td width="17%" class="table_headline"><strong>Error Name</strong></td>
    <td width="17%" class="table_headline"><strong>Error Code</strong></td>
    <td width="83%" class="table_headline"><strong>Comment</strong></td>
  </tr>
  <tr>
    <td>EINVPARAM</td>
    <td>5003</td>
    <td>Invalid parameters.</td>
  </tr>
</table>

<h5>Description</h5>
<p>The <strong>socket</strong> methods creates a new socket. The is no limits for the number of UDT sockets in one system, as long as there is enough system 
resource. UDT supports both IPv4 and IPv6, which can be selected by the <i>af</i> parameter. On the other hand, two socket types are supports in UDT, i.e., 
SOCK_STREAM for data streaming and SOCK_DGRAM for messaging. Note that UDT sockets are connection oriented in all cases.</p>

<h5>See Also</h5>
<p><strong><a href="close.htm">close</a></strong></p>

<p>&nbsp;</p>

</body>
</html>
